#include <macro.h>

void other_QR_code(MacroOper macroOper, int board_index)
{
	unsigned short data[20];
	unsigned short err0=GetMemEx(data,@4X0_1@,2199,20,DATA_INT16);
	if(err0!=1) GetMemEx(data,@4X0_1@,2199,20,DATA_INT16);
	
	SetWord(@lw0@, 100, strlen((char *)data));
	
	unsigned short QR_Code_1[20] = {0};
	unsigned short QR_Code_2[20] = {0};
	unsigned short QR_Code_3[20] = {0};
	unsigned short QR_Code_4[20] = {0};
	sprintf((char *)QR_Code_1, "%s_1", (char *)data);
	sprintf((char *)QR_Code_2, "%s_2", (char *)data);
	sprintf((char *)QR_Code_3, "%s_3", (char *)data);
	sprintf((char *)QR_Code_4, "%s_4", (char *)data);
	
	unsigned short err1=SetMemEx(QR_Code_1,@lw0@,201,20,DATA_INT16);
	if(err1!=1) SetMemEx(QR_Code_1,@lw0@,201,20,DATA_INT16);
	
	unsigned short err2=SetMemEx(QR_Code_2,@lw0@,221,20,DATA_INT16);
	if(err2!=1) SetMemEx(QR_Code_2,@lw0@,221,20,DATA_INT16);
	
	unsigned short err3=SetMemEx(QR_Code_3,@lw0@,241,20,DATA_INT16);
	if(err3!=1) SetMemEx(QR_Code_3,@lw0@,241,20,DATA_INT16);
	
	unsigned short err4=SetMemEx(QR_Code_4,@lw0@,261,20,DATA_INT16);
	if(err4!=1) SetMemEx(QR_Code_4,@lw0@,261,20,DATA_INT16);
}

void ZR_new_QR_code(MacroOper macroOper, int board_index)
{
	unsigned short data[256];
	unsigned short QR_Code[256] = {0};
	
    if(board_index == 1) {
        if(GetWord(@4X0_1@,211) != 1) {
            return;
        }

        // 1号板
        unsigned short err0=GetMemEx(data,@4X0_1@,3412,256,DATA_INT16);
        if(err0!=1) GetMemEx(data,@4X0_1@,3412,256,DATA_INT16);
        
        sprintf((char *)QR_Code, "%s", (char *)data);
        unsigned short err1=SetMemEx(QR_Code,@lw0@,2000,256,DATA_INT16);
        if(err1!=1) SetMemEx(QR_Code,@lw0@,2000,256,DATA_INT16);
    }
    else if(board_index == 2) {
        if(GetWord(@4X0_2@,211) != 1) {
            return;
        }

        // 2号板
        unsigned short err0=GetMemEx(data,@4X0_2@,3412,256,DATA_INT16);
        if(err0!=1) GetMemEx(data,@4X0_2@,3412,256,DATA_INT16);
        
        sprintf((char *)QR_Code, "%s", (char *)data);
        unsigned short err1=SetMemEx(QR_Code,@lw0@,2300,256,DATA_INT16);
        if(err1!=1) SetMemEx(QR_Code,@lw0@,2300,256,DATA_INT16);
    }
}

int MacroMain()
{
	ZR_new_QR_code(macroOper, 1);
	ZR_new_QR_code(macroOper, 2);
	
	return 0;
}